<?php
require_once 'inc/CorePage.php';
class TalPage extends CorePage {
	protected $items = array(
		array (
			'title' => 'tal:define',
			'urls' => array(
				'http://wiki.zope.org/ZPT/TALSpecification14#define',
				'http://phptal.motion-twin.com/manual/en/#tal-define',
			),
			'body' => 'Allows to define variables. MicroTal is very limited and has only one scope of variables - each new define overrides previous one. There is also no support for local/global keywords',
			'support' => 'partial - global & local are ignored',
			'syntax' => '[global|local] name(string) value(expression)[;name(string) value(expression)]',
			'examples' => array (
				array('template'=>'<p tal:define="mytitle string:Title;tlen php:strlen(${mytitle})" tal:content="tlen" />'),
			),
		),
		array (
			'title' => 'tal:attributes',
			'urls' => array(
				'http://wiki.zope.org/ZPT/TALSpecification14#attributes',
				'http://phptal.motion-twin.com/manual/en/#tal-attributes',
			),
			'body' => 'Can be used to add attributes to tag. If attribute value evaluates to false it is skipped',
			'support' => 'ok :)',
			'syntax' => 'name(string) value(expression)[;name(string) value(expression)]',
			'examples' => array (
				array('template' => '<input tal:attributes="checked php:true"/>'),
				array('template' => '<input tal:attributes="readonly php:false;class string:funny" />'),
			),
		),
		array (
			'title' => 'tal:condition',
			'urls' => array(
				'http://wiki.zope.org/ZPT/TALSpecification14#condition',
				'http://phptal.motion-twin.com/manual/en/#tal-condition',
			),
			'body' => 'Quite self explaining. For MicroTal everything other than false is true.	If variable doesn\'t exists it evalueates to false;',
			'support' => 'ok :)',
			'syntax' => 'condition(expression)',
			'examples' => array (
				array('template' => '1 <p tal:condition="php: (1%2==1)">odd</p><p tal:condition="php: (1%2 ==0)">even</p>'),
				array('template' => 'God <tal:block tal:condition="God">exists</tal:block><tal:block tal:condition="not:God">doesn\'t texists</tal:block>'),
			),
		),
		array (
			'title' => 'tal:repeat',
			'urls' => array(
				'http://wiki.zope.org/ZPT/TALSpecification14#repeat',
				'http://phptal.motion-twin.com/manual/en/#tal-repeat',
			),
			'support' => 'ok :)',
			'syntax' => 'item(string) array(expression)',
			'examples' => array (
				array(
					'rawresult',
					'data' => array (
						'table' => array(
							array('Ger', 'Pl'),
							array('Eins', 'Jeden'),
							array('Zwei', 'Dwa'),
							array('Drei', 'Trzy'),
							array('Vier', 'Cztery'),
							array('Fünf','Pięć'),
							array('Sechs','Sześć'),
							array('Sieben','Siedem'),
							array('Acht','Osiem'),
							array('Neun','Dziewięć'),
							array('die Sonne','Słońce'),
						),
					),
					'template' => '	<table>
				<tr tal:repeat="row table">
					<tal:block tal:define="color string:color:blue;"/>
					<tal:block tal:condition="path:repeat/row/start">
					<tal:block tal:define="color string:color:green;"/>
					</tal:block>

					<tal:block tal:define="background string:"/>
					<tal:block tal:condition="path:repeat/row/odd">
					<tal:block tal:define="background string:background:gray;"/>
					</tal:block>

					<tal:block tal:define="text string:"/>
					<tal:block tal:condition="path:repeat/row/end">
					<tal:block tal:define="text string:text-decoration:underline;"/>
					</tal:block>
					<tal:block tal:define="style string:${color}${background}${text}"/>

					<th tal:attributes="style path:style" tal:repeat="cell row" tal:condition="path:repeat/row/start" tal:content="cell" />
					<td tal:attributes="style path:style" tal:repeat="cell row" tal:condition="not:path:repeat/row/start" tal:content="cell" />
				</tr>
			</table>'
				),
				array(
					'rawresult',
					'template' => '
			<table>
				<tr>
					<th>key</th>
					<th>index</th>
					<th>number</th>
					<th>even</th>
					<th>odd</th>
					<th>start</th>
					<th>end</th>
					<th>letter</th>
					<th>Letter</th>
					<th>roman</th>
					<th>Roman</th>
					<th>Stupid</th>
				</tr>
				<tr tal:repeat="row php:range(1,27)">
					<td tal:content="repeat/row/key" />
					<td tal:content="repeat/row/index" />
					<td tal:content="repeat/row/number" />
					<td tal:content="repeat/row/even" />
					<td tal:content="repeat/row/odd" />
					<td tal:content="repeat/row/start" />
					<td tal:content="repeat/row/end" />
					<td tal:content="repeat/row/letter" />
					<td tal:content="repeat/row/Letter" />
					<td tal:content="repeat/row/roman" />
					<td tal:content="repeat/row/Roman" />
					<td tal:content="${repeat/row/key}" />
				</tr>
			</table>',
				),
			),
		),
		array (
			'title' => 'tal:omit-tag',
			'urls' => array(
				'http://wiki.zope.org/ZPT/TALSpecification14#omit-tag',
				'http://phptal.motion-twin.com/manual/en/#tal-omit-tag',
			),
			'support' => 'ok :)',
			'syntax' => '[condition(expression)]',
			'examples' => array (
				array('template' => '<b tal:omit-tag="php:(2==3)">this is bold</b><i tal:omit-tag="">this is not italic</i>'),
			),
		),
		array (
			'title' => 'tal:content',
			'urls' => array(
				'http://wiki.zope.org/ZPT/TALSpecification14#content',
				'http://phptal.motion-twin.com/manual/en/#tal-content',
			),
			'support' => 'ok :)',
			'syntax' => 'value(expression)',
			'examples' => array (
				array('template' => '<span tal:define="myvar string:my string"/><span tal:content="myvar">will be replaced</span>'),
			),
		),
		array (
			'title' => 'tal:replace',
			'urls' => array(
				'http://wiki.zope.org/ZPT/TALSpecification14#replace',
				'http://phptal.motion-twin.com/manual/en/#tal-replace',
			),
			'body' => 'replace = content + omit-tag',
			'support' => 'ok :)',
			'syntax' => 'value(expression)',
			'examples' => array (
				array('template' => '<span tal:replace="string:this beautyful string">this ugly string and span</span>'),
			),
		),
		

	
	);
	function __construct() {
		//parent::__construct();

	}

    public $examples = array (
	
	'exE' => array('template'=> '

  <ul metal:define-macro="show-list">
            <li tal:repeat="item list">
                <tal:block tal:condition="php:is_array(${item})" tal:define="list item"><tal:block metal:use-macro="show-list" /></tal:block>
                <tal:block tal:condition="php:!is_array(${item})" tal:content="item" />
            </li>
        </ul> <tal:block tal:define="list php:array(\'a\',array(\'b\',\'c\'=>array(\'r\'=>\'f\')))" /> <p metal:use-macro="show-list" />  ')
	);
}

